home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / backup / kbackup-.000 / KBackup-1.2.7.tar / KBackup / src / verify_src < prev    next >
Text File  |  1996-02-13  |  7KB  |  252 lines

  1. #
  2. # /home/kbackup/.CVSROOT/KBackup/src/verify_src,v 1.13 1996/02/13 20:50:03 kbackup Exp
  3. #
  4. # This file is Copyright (C) 1995 by Karsten Ballⁿder
  5. #                Karsten.Ballueder@stud.uni-karlsruhe.de
  6. #
  7. # It is part of the KBackup package, see the file COPYING for details.
  8. #
  9. #
  10. #    subroutine for verifying existing archives
  11. #    uses read_data() for input
  12. #
  13. #
  14.  
  15. if [ "ReadData_src_loaded" != "YES" ]
  16. then
  17.     . $SRCDIR/$READDATA_SRC
  18. fi
  19.  
  20. Verify_src_loaded=YES
  21.  
  22. Verify_II()    # accepts option "auto" to avoid insert-media-prompt
  23. {
  24.     save_options
  25.     backup_filesperarchive="???"
  26.     backup_version="???"
  27.     backup_date="???"
  28.     backup_compression="???"
  29.     backup_type="???"
  30.     backup_archive_format="???"
  31.     backup_multivolume="???"
  32.     backup_donly="???"
  33.     backup_use_multibuf="???"
  34.     backup_multibuf_seq_info="???"
  35.     backup_multibuf_blksize="???"
  36.     backup_multibuf_nblocks="???"
  37.     backup_parent="???"
  38.  
  39.     old_compression="$compression"
  40.     
  41.     if [ "$device_type" = "FLOPPY" ]
  42.     then
  43.         ErrorBox "Verify for disk archives not implemented."
  44.         return
  45.     fi
  46.  
  47.     if [ "$1" != "auto" ]
  48.     then
  49.         insert_media
  50.         if [ $? != 0 ] 
  51.         then
  52.             return
  53.         fi
  54.     fi    
  55.  
  56.     auto_rewind
  57.     
  58.     if [ "$device_type" = "TAPE" ]
  59.     then
  60.         InfoBox "Reading header..." 
  61.         read_data -raw $device >$TMP/$TMPFILE 2>$STDERR
  62.         check_error -dev
  63.         if [ $? != 0 ]
  64.         then
  65.             return
  66.         fi
  67.         retry=2
  68.         while [ $retry -gt 0 ]
  69.         do
  70.             read firstline < $TMP/$TMPFILE 
  71.             if [ $? = 0 ] && [ "$firstline" = "#KBackup" ]
  72.             then
  73.                 retry=0
  74.                 backup_use_multibuf="???"
  75.                 . $TMP/$TMPFILE
  76.                 compression="$backup_compression"
  77.                 if [ "$backup_use_multibuf" = "YES" ]
  78.                 then
  79.                     use_multibuf="$backup_use_multibuf"
  80.                     multibuf_blksize="$backup_multibuf_blksize"
  81.                     multibuf_nblocks="$backup_multibuf_nblocks"
  82.                     multibuf_seq_info="$backup_multibuf_seq_info"
  83.                 else
  84.                     use_multibuf=NO
  85.                 fi
  86.             else
  87.                 if [ "$1" != "auto" ] || [ $retry -eq 1 ]
  88.                 then
  89.                     ErrorBox "No valid KBackup Archive Header."
  90.                     return
  91.                 else
  92.                     MsgBox \
  93. "Cannot read archive header.
  94. If this is a multivolume archive,
  95. please insert the first volume!"
  96.                     retry=`expr $retry - 1`
  97.                 fi
  98.             fi
  99.         done # while retry    
  100.         report "Verify: Archive header:     OK"
  101.         
  102.         dirstatus=
  103.         archstatus=        
  104.                 
  105.         $DIALOG   --title "Verify" --infobox "\n\
  106. Archive created by KBackup Version: $backup_version\n\
  107.   files per archive: .............. $backup_filesperarchive\n\
  108. Creation date: .................... $backup_date\n\
  109. Backup type: ...................... $backup_type\n\
  110. Archive format: ................... $backup_archive_format\n\
  111. Compression method: ............... $backup_compression\n\
  112. Directories-only flag: ............ $backup_donly\n\
  113.   using Multibuf: ................. $backup_use_multibuf\n\
  114.   Multibuf blocksize: ............. $backup_multibuf_blksize\n\
  115.   Multibuf number of blocks: ...... $backup_multibuf_nblocks\n\
  116. \n\
  117. Parent directory of backup: ....... $backup_parent\n\
  118. Contents directory: ............... $dirstatus\n\
  119. Archive status: ................... $archstatus" 20 75 
  120.         case $backup_compression in
  121.             GZIP) ;;
  122.             COMPRESS) ;;
  123.             NONE) ;;
  124.             PGP) ;;
  125.             *)    beep
  126.                 $DIALOG   --title "Error" --msgbox "\nNo KBackup archive or\nunknown compression method." 7 40
  127.                 backup_compression="???"
  128.                 restore_options
  129.                 return ;;
  130.         esac
  131.         if [ "$backup_compression" != "???" ] ; then
  132.             compression="$backup_compression"
  133.             set_compress
  134.             if [ "$backup_compression" = "PGP" ]
  135.             then
  136.                 GetPGPPASS
  137.             fi
  138.         fi
  139.  
  140.             $DIALOG   --title "Verify" --infobox "\n\
  141. Archive created by KBackup Version: $backup_version\n\
  142.   files per archive: .............. $backup_filesperarchive\n\
  143. Creation date: .................... $backup_date\n\
  144. Backup type: ...................... $backup_type\n\
  145. Archive format: ................... $backup_archive_format\n\
  146. Compression method: ............... $backup_compression\n\
  147. Directories-only flag: ............ $backup_donly\n\
  148.   using Multibuf: ................. $backup_use_multibuf\n\
  149.   Multibuf blocksize: ............. $backup_multibuf_blksize\n\
  150.   Multibuf number of blocks: ...... $backup_multibuf_nblocks\n\
  151. \n\
  152. Parent directory of backup: ....... $backup_parent\n\
  153. Contents directory: ............... $dirstatus\n\
  154. Archive status: ................... $archstatus" 20 75 
  155.         (read_data | $uncompress )>/dev/null 2>$STDERR 3<$TMP/$PHRASEFILE </dev/null
  156.         if check_compress_success
  157.         then
  158.             dirstatus=OK
  159.             report "Verify: Contents directory: OK"
  160.         else
  161.             dirstatus=ERR
  162.             report "Verify: Contents directory: Corrupted"
  163.             beep
  164.             $DIALOG   --title "Error" --yesno "\nContents directory corrupted.\nCheck archive contents anyway?" 8 40
  165.             if [ $? != 0 ]
  166.             then
  167.                 restore_options
  168.                 clear_PGP
  169.                 return
  170.             fi
  171.         fi
  172.             $DIALOG   --title "Verify" --infobox "\n\
  173. Archive created by KBackup Version: $backup_version\n\
  174.   files per archive: .............. $backup_filesperarchive\n\
  175. Creation date: .................... $backup_date\n\
  176. Backup type: ...................... $backup_type\n\
  177. Archive format: ................... $backup_archive_format\n\
  178. Compression method: ............... $backup_compression\n\
  179. Directories-only flag: ............ $backup_donly\n\
  180.   using Multibuf: ................. $backup_use_multibuf\n\
  181.   Multibuf blocksize: ............. $backup_multibuf_blksize\n\
  182.   Multibuf number of blocks: ...... $backup_multibuf_nblocks\n\
  183. \n\
  184. Parent directory of backup: ....... $backup_parent\n\
  185. Contents directory: ............... $dirstatus\n\
  186. Archive status: ................... $archstatus" 20 75 
  187.  
  188.         if [ $backup_archive_format = TAR ]
  189.         then
  190.             (read_data | $uncompress | $TAR $xopt -t -f -) 2>$STDERR >/dev/null 3<$TMP/$PHRASEFILE </dev/null
  191.         else    # AFIO
  192.             xopt=
  193.             if [ "$device_type" = "FLOPPY" ]
  194.             then
  195.                 blocks=`echo $floppy_format|$SED '1,$ s/\(.*\)\/.*/\1k/g' `
  196.                 xopt="$xopt -F -s $blocks "
  197.             fi
  198.     
  199.             if [ "$compression" = "GZIP" ]
  200.             then
  201.                 xopt="$xopt -Z"
  202.                 num=`echo $compress_options | $SED '1,$ s/-\([0-9]\).*/\1/g'`
  203.                 case "$num" in
  204.                 "0"|"1"|"2"|"4"|"5"|"6"|"7"|"8"|"9")
  205.                     xopt="$xopt -G $num"
  206.                     ;;
  207.                 esac
  208.             fi
  209.             
  210.             ( read_data | $AFIO -t $xopt - ) 2>$STDERR 3<$TMP/$PHRASEFILE
  211.             if [ $? != 0 ]
  212.             then
  213.                 ErrorBox "Archive is corrupted."    
  214.                 restore_options
  215.                 clear_PGP    
  216.                 return
  217.             fi
  218.         fi
  219.  
  220.         if [ $? -eq 0 ]
  221.         then
  222.             archstatus=OK
  223.         else
  224.             archstatus=Corrupted
  225.         fi
  226.         
  227.         report "Verify: Archive status:     $archstatus"
  228.  
  229.         $DIALOG   --title "Verify" --msgbox "\n\
  230. Archive created by KBackup Version: $backup_version\n\
  231.   files per archive: .............. $backup_filesperarchive\n\
  232. Creation date: .................... $backup_date\n\
  233. Backup type: ...................... $backup_type\n\
  234. Archive format: ................... $backup_archive_format\n\
  235. Compression method: ............... $backup_compression\n\
  236. Directories-only flag: ............ $backup_donly\n\
  237.   using Multibuf: ................. $backup_use_multibuf\n\
  238.   Multibuf blocksize: ............. $backup_multibuf_blksize\n\
  239.   Multibuf number of blocks: ...... $backup_multibuf_nblocks\n\
  240. \n\
  241. Parent directory of backup: ....... $backup_parent\n\
  242. Contents directory: ............... $dirstatus\n\
  243. Archive status: ................... $archstatus" 20 75 
  244.     else
  245.         beep
  246.         $DIALOG   --title "Error" --msgbox "\nThere's no verify for files." 7 40
  247.     fi
  248.     clear_PGP
  249.     restore_options
  250. }
  251.  
  252.